package com.pkk.penguin.frame.know.shiro.shirodemo.util.shiro;

import com.hazelcast.util.MD5Util;
import com.pkk.penguin.frame.know.shiro.shirodemo.springversion.entity.TbUserEntity;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.crypto.RandomNumberGenerator;
import org.apache.shiro.crypto.SecureRandomNumberGenerator;


/**
 * @description: 密码操作
 * @author: peikunkun
 * @create: 2018-08-21 17:33
 **/
public class PasswordHelper {

  private final int hashIterations = 2;

  private RandomNumberGenerator randomNumberGenerator = new SecureRandomNumberGenerator();
  private String algorithmName = "md5";

  /**
   * @Description: 密码加密
   * @Param: [sUser]
   * @return: void
   * @Author: peikunkun
   * @Date: 2018/8/21 0021 下午 6:24
   */
  public void encryPasssword(TbUserEntity tbUserEntity) {
    if (tbUserEntity == null || StringUtils.isBlank(tbUserEntity.getPwd())) {
      return;
    }
    tbUserEntity.setPwd(MD5Util.toMD5String(tbUserEntity.getPwd()));
  }


}
